package com.yxboot.modules.audio.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yxboot.common.api.Result;
import com.yxboot.common.aspect.SysLogOperation;
import com.yxboot.common.pagination.PageRequest;
import com.yxboot.modules.audio.entity.AudioDetail;
import com.yxboot.modules.audio.service.AudioDetailService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 *  Api
 * @author exchenming
 * @date 2025-08-19
 */
@RestController
@RequestMapping("/audio/detail")
@RequiredArgsConstructor
@Tag(name = " Api")
public class AudioDetailController {
    private final AudioDetailService audioDetailService;

    @GetMapping("/list")
    @Operation(summary = " 查询列表接口")
    public Result list(PageRequest pageRequest) {
        IPage<AudioDetail> pageResult = audioDetailService.pageQuery(pageRequest);
        return Result.success("查询成功！", pageResult);
    }

    @GetMapping("/get")
    @Operation(summary = "查询详情接口")
    public Result get(@RequestParam Long flowno) {
        AudioDetail audioDetail = audioDetailService.getById(flowno);
        return Result.success("查询成功！", audioDetail);
    }

    @PostMapping("/save")
    @SysLogOperation(value = "保存信息接口")
    @Operation(summary = "保存信息接口")
    public Result save(@RequestBody AudioDetail audioDetail) {
        audioDetailService.saveOrUpdate(audioDetail);
        return Result.success("保存成功！", audioDetail);
    }

    @DeleteMapping("/remove")
    @SysLogOperation(value = "删除信息接口")
    @Operation(summary = "删除信息接口")
    public Result remove(Long flowno) {
        audioDetailService.removeById(flowno);
        return Result.success("删除成功！");
    }
}